package com.wuge.gulimall.product.web;

import com.wuge.gulimall.product.entity.CategoryEntity;
import com.wuge.gulimall.product.service.CategoryService;
import com.wuge.gulimall.product.vo.Catelog2Vo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

@Controller
public class IndexController {
    @Autowired
   private CategoryService categoryService;
    @RequestMapping({"/","index.html"})
    public String index(Model model){
        List<CategoryEntity> list=categoryService.getCatelog1level();
        model.addAttribute("categorys",list);
        return "index";
    }
    @RequestMapping({"/catelog2"})
    @ResponseBody
    public Map<String, List<Catelog2Vo>> getCatelog2(){
        Map<String, List<Catelog2Vo>> map=categoryService.getCatelog2level();

        return map;
    }
}
